<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>    
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="${pageContext.request.contextPath }/jsp/css/bootstrap.css" rel="stylesheet">
<link href="${pageContext.request.contextPath }/jsp/css/style.css" rel="stylesheet">
<script src="${pageContext.request.contextPath }/jsp/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath }/jsp/js/bootstrap.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Merchant List</title>
</head>
<body class="layout-background">
<nav class="navbar navbar-default nav-bar">
    <div class="layout-width" >
        <div class="navbar-header">
            <a href="./listMerchant" class="navbar-brand">ITA Order System</a>
        </div>
        <div class="pull-right" style="font-size: 20px;position: relative;top: 10px;right: 55px;">
	        <c:choose>
	        	<c:when test="${user != null }">
		            <label class="control-label">Hello: </label>
		            <a href="#">${user.cname }</a>
		            <div style="margin-left: 70px;margin-top: -8px;">
		                <a class="btn btn-danger btn-xs" href="./logout">Logout</a>
		            </div>
	        	</c:when>
	        	<c:otherwise>
	        		<div style="margin-left: 70px;margin-top: -8px;">
		                <a class="btn btn-primary btn-sm" href="./login">Login</a>
		            </div>
	        	</c:otherwise>
	        </c:choose>
        </div>
    </div>
</nav>

<div class="layout-width" style="line-height: 50px">
</div>
<div class="layout-width" style="line-height: 50px">
</div>

<div class="layout-width merchant-list clearfix">
<c:forEach var="merchant" items="${merchantList}">
    <div class="merchant-outside">
        <div style="width: 95%;margin: 10px 5px 0 10px;border: 1px solid #ddd;height: 310px;">
            <a class="merchant-a" href="./listDish?mid=${merchant.mid }">
                <div class="merchant-logo">
                    <img class="merchant-logo-img" src="http://10.222.232.146:9000/ita_order_system_merchant/${merchant.logo }"/>
                </div>
            </a>
            <div style="position: relative;right: -17%;margin-top: -10px;">
                <label class="control-label">Name: </label><a href="./listDish?mid=${merchant.mid }">${merchant.mname}</a><br/>
                <label class="control-label">Tel: </label><a href="./listDish?mid=${merchant.mid }">${merchant.tel}</a><br/>
                <label class="control-label">Address: </label><a href="./listDish?mid=${merchant.mid }">${merchant.address }</a>

            </div>
        </div>
    </div>
</c:forEach>

</div>

<div class="layout-width merchant-botton">
    <nav>
        <ul class="pagination">
            <li class="disabled">
             <c:choose>
            <c:when test="${currentPage == 1}">
            <li class="disabled">
            <a href="#" aria-label="Previous">
	                    <span aria-hidden="true">&laquo;</span>
	                </a>
	                </li>
	                </c:when>
            <c:otherwise>
            <li>
	            <a href="./listMerchant?page=${currentPage - 1}" aria-label="Previous">
	                    <span aria-hidden="true">&laquo;</span>
	                </a>
            </li>
            </c:otherwise>
            </c:choose>
                
            </li>
            <c:forEach var="page" items="${totalPage }">
            	<c:choose>
            		<c:when test="${page == currentPage}">
			            <li class="active">
			                <a href="#">${page } <span class="sr-only">(current)</span></a>
			            </li>            			
            		</c:when>
            		<c:otherwise>
	            		<li>
		                	<a href="./listMerchant?page=${page }">${page }</a>
		            	</li>
            		</c:otherwise>
            	</c:choose>
            </c:forEach>
            
            
             <c:choose>
            <c:when test="${currentPage == totalPage.size()}">
            <li class="disabled">
            <a href="#" aria-label="Next">
                    <span aria-hidden="true">&raquo;</span>
                </a>
	                </li>
	                </c:when>
            <c:otherwise>
            <li>
	            <li>
                <a href="./listMerchant?page=${currentPage + 1}" aria-label="Next">
                    <span aria-hidden="true">&raquo;</span>
                </a>
            </li>
            </c:otherwise>
            </c:choose>
            

        </ul>
    </nav>
</div>

</body>
</html>